<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<script src="<c:url value='/js/jquery/jqueryFileTree/jqueryFileTree.js' />" type="text/javascript"></script>
<script src="<c:url value='/js/file-browser.js' />" type="text/javascript"></script>
<link href="<c:url value='/js/jquery/jqueryFileTree/jqueryFileTree.css' />" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	$(document)
			.ready(
					function() {
						$('#pageTitle').text('<spring:message code="editCipeprojectDetail.heading" />');

						$.validator.addMethod("endDateValidation", function(value, element) {
							var date_ini = new Date($('#projectStartDate').val()).getTime();
							var date_end = new Date($('#projectEndDate').val()).getTime();
							if (isNaN(date_ini)) {
								//if required we will add code
							} else if (isNaN(date_end)) {
								//if required we will add code
							} else if (date_ini > date_end) {
								return false;

							}
							return true;
						},  "Project End Date must be greater than the Project Start Date."
						);

						$.validator.addMethod("startDateValidation", function(value, element) {
							var date_ini = new Date($('#projectStartDate').val()).getTime();
							var date_end = new Date($('#projectEndDate').val()).getTime();
							if (isNaN(date_ini)) {
							} else if (isNaN(date_end)) {
							} else if (date_ini > date_end) {
								return false;

							}
							return true;
						},  "Project Start Date must be less than the Project End Date."
						);
						
						$.validator.addMethod("startDateValidateDonorAward",function(value,element){
						  	var date_ini = new Date($('#projectStartDate').val()).getTime();
							var date_end = new Date($('#donorStartDate').val()).getTime();
							if (isNaN(date_ini)) {
							} else if (isNaN(date_end)) {
							} else if (date_ini < date_end) {
								return false;
							}
							return true;
						 },
						  "Project Start Date must be greater than or equal to the Donor Award Start Date."
						 );

						$.validator.addMethod("endDateValidateDonorAward",function(value,element){
						  	var date_ini = new Date($('#projectEndDate').val()).getTime();
							var date_end = new Date($('#donorEndDate').val()).getTime();
							if (isNaN(date_ini)) {
							} else if (isNaN(date_end)) {
							} else if (date_ini > date_end) {
								return false;
							}
							return true;
						 },
						  "Project End Date must be less than or equal to Donor Award End Date."
						 );
						
						$.validator.addMethod("startDateDonorEndDateValidateDonorAward",function(value,element){
						  	var date_ini = new Date($('#projectStartDate').val()).getTime();
							var date_end = new Date($('#donorEndDate').val()).getTime();
							if (isNaN(date_ini)) {
							} else if (isNaN(date_end)) {
							} else if (date_ini > date_end) {
								return false;
							}
							return true;
						 },
						  "Project Start Date must be less than or equal to the Donor Award End Date."
						 );

						$.validator.addMethod("endDateDonorStartDateValidateDonorAward",function(value,element){
						  	var date_ini = new Date($('#projectEndDate').val()).getTime();
							var date_end = new Date($('#donorStartDate').val()).getTime();
							if (isNaN(date_ini)) {
							} else if (isNaN(date_end)) {
							} else if (date_ini < date_end) {
								return false;
							}
							return true;
						 },
						  "Project End Date must be greater than or equal to the Donor Award Start Date."
						 );
						 
						$("#editCipeprojectForm").validate({
							rules : {
								partner : {
									required : true
								},
								acronym : {
									required : true
								},
								costCenterNumber : {
									required : true
								},
								projectTitle : {
									required : true
								},
								donoraward : {
									required : true
								},
								projectStartDate : {
									required : true,
									startDateValidation : true,
									startDateValidateDonorAward : true,
									startDateDonorEndDateValidateDonorAward : true
								},
								projectEndDate : {
									required : true,
									endDateValidation : true,
									endDateValidateDonorAward : true,
									endDateDonorStartDateValidateDonorAward : true
								},
								cipeprojecttype : {
									required : true
								},
								cipeprojectstatus : {
									required : true
								},
								region : {
									required : true
								},
								country : {
									required : true
								},
								seniorProgramOfficer : {
									required : true
								},
								programOfficer : {
									required : true
								},
								programAssistant : {
									required : true
								},
								managementFunds : {
									required : true
								}
							}

						});

						$("#regions").bind("change", function() {
							loadDataViaAjax("loadCountries.do", {
								"regionId" : this.value
							}, parseCountriesJson);
						});

						$("#countries")
								.bind(
										"change",
										function() {
											loadDataViaAjax(
													"loadCountryUsers.do",
													{
														"countryId" : this.value
													},
													function(result) {
														$("#programOfficer").get(0).value = result.programOfficer ? result.programOfficer
																: "";
														$("#programAssistant").get(0).value = result.programAssistant ? result.programAssistant
																: "";
													});
										});

					//	$("#regions").trigger("change");

						$('#donorawardId').change(function() {
							loadDataViaAjax("getDonorAwardBean.do", {
								"donorawardId" : this.value
							}, function(bean) {
								$('#donorName').val((bean.donorName) ? bean.donorName : '');
								$('#donorStartDate').val((bean.formattedStartDate) ? bean.formattedStartDate : '');
								$('#donorEndDate').val(bean.formattedEndDate ? bean.formattedEndDate : '');
							});
						});
						$('#donorawardId').change();

						$("#projectStartDate").bind("change", getFiscalYear).trigger("change");
						$("#projectStartDate").change();

						//disabledControls();

						$('#view-knowledgemanagement').click(function() {
							loadDiv('content', 'showEditKnowledgeManagement.do?id=' + $(this).attr('cipeprojectId'));
						});

						$('#mail-to-trigger')
								.click(
										function() {
											window.location = 'mailto:grantsmanagement@cipe.org?Subject=Data%20Discrepency%20Found%20-%20Project%20#%20' + $(this).attr('cipeprojectId');
										});
						$('#view-modifications').click(function() {
							loadDiv('content', 'showCipeprojectModifications.do?id=' + $(this).attr('cipeprojectId'));
						});
						$('#view-rollup').click(function() {
							loadDiv('content', 'showCipeprojectSummary.do?id=' + $(this).attr('cipeprojectId'));
						});
						$('#view-loggedpayments').click(function() {
							loadDiv('content', 'showCipeprojectPaymentRequestLineItems.do?id=' + $(this).attr('cipeprojectId'));
						});
						$('.view-cipeprojectdetail-link').click(function() {
							loadDiv('content', 'showEditCipeprojectDetail.do?id=' + $(this).attr('cipeprojectId'));
						});
						$('.view-cipeprojectsummary-link').click(function() {
							loadDiv('content', 'showCipeprojectSummary.do?id=' + $(this).attr('cipeprojectId'));
						});
						$('.add-reporting-link').click(function() {
							loadDiv('content', 'showAddReportingrequirements.do');
						});

						$("#projectStartDate").datepicker();
						$("#projectEndDate").datepicker();

						$("#projectStartDate").datepicker();
						$("#projectEndDate").datepicker();

						$('#add-partner').click(function() {
							loadDiv('content', 'showAddPartnergrant.do');
						});

						$('.close-button').click(function() {
							if (confirm('Are you sure you want to close the form?')) {
								window.location = '../secure/showDashboard.do';
							}
						});

						var fileBrowser = new FileBrowser('S:/scanned documents/','<c:url value="/js/jquery/jqueryFileTree/connectors/jqueryFileTree.jsp" />', 
								function(file) {
									$('#modificationDocumentLocation').val(file);
								},
								function(dir) {
									$('#modificationDocumentLocation').val(dir);
								}
						);
						
						$('#chooseFileButton').click(function() {
							fileBrowser.open();
						});	
						
						$('#editButton').click(function() {
							loadDiv('content', 'showEditCipeprojectDetail.do?editable=true&id=' + $(this).attr('cipeprojectId'));
						});

						$('#cancelButton')
								.click(
										function() {
											var ans = confirm('Are you sure you want to cancel editing this record without saving it?');
											if (ans) {
												loadDiv('content', 'showEditCipeprojectDetail.do?editable=false&id=' + $(this).attr('cipeprojectId'));
											}
										});

						$('.edit-partnergrant-link').click(function() {
							loadDiv('content', 'showEditPartnergrantView.do?id=' + $(this).attr('partnergrantId'));
						});
						
						sortDropDownListByText();

						enableDisabledControls();
	});
	
	function enableDisabledControls() {
		<c:if test="${cipeproject.id !=null and cipeproject.id gt 0}">
		 <c:choose>
		  <c:when test="${param.editable=='true'}">
			$("form :input").removeAttr("disabled","disabled");
			$("#donorName").attr("readonly","readonly");
			$("#donorStartDate").attr("readonly","readonly");
			$("#donorEndDate").attr("readonly","readonly");

			$("#projectID").attr("readonly","readonly");
			$("#createdBy").attr("disabled","disabled");
			$("#creationDate").attr("readonly","readonly");
			$("#updatedBy").attr("disabled","disabled");
			$("#updationDate").attr("readonly","readonly");
			$("#loginFormSubmit").removeAttr("disabled","disabled");
			$("#cancelButton").removeAttr("disabled","disabled");
			$("#editButton").attr("disabled","disabled");
		  </c:when>
		  <c:otherwise>
			$("form :input").attr("disabled","disabled");
			$("input[type^='button']").removeAttr("disabled","disabled");
			$("input[type^='submit']").removeAttr("disabled","disabled");
			$("#loginFormSubmit").attr("disabled","disabled");
			$("#cancelButton").attr("disabled","disabled");
			$("#editButton").removeAttr("disabled","disabled");
		  </c:otherwise>
		 </c:choose>
		</c:if>
	}

	function getFiscalYear() {

		var str1 = document.getElementById("projectStartDate").value;

		var mon1 = parseInt(str1.substring(0, 2), 10);
		var dt1 = parseInt(str1.substring(3, 5), 10);
		var yr1 = parseInt(str1.substring(6, 10), 10);
		var dt2 = 1;
		var mon2 = 10;

		var date1 = new Date(yr1, mon1, dt1);
		var date2 = new Date(yr1, mon2, dt2);

		if (isNaN(yr1)) {
			//do nothing
		} else {

			if (date1 >= date2) {
				document.getElementById("fiscalYear").value = yr1 + 1;
			} else {
				document.getElementById("fiscalYear").value = parseInt(yr1);
			}
		}
	}

	function parseCountriesJson(data) {
		var html = "<option value=''>Select</option>";
		var directorId = "";
		if (data) {
			for (p in data) {
				if (p != 'director') {
					html += "<option value='" + p + "'>" + data[p] + "</option>";
				} else {
					directorId = data[p];
				}
			}
		}
		$("#countries option").remove();
		$("#countries").append(html).trigger("change");
		$("#seniorProgramOfficer").get(0).value = directorId;
		sortDropDownListByText();
	}

	function sortDropDownListByText(obj) {
		// Loop for each select element on the page.

		$("select").each(function() {

			// Keep track of the selected option.
			var selectedValue = $(this).val();
			// Sort all the options by text.
			$(this).html($("option", $(this)).sort(function(a, b) {
				return a.text == b.text ? 0 : ((a.text < b.text) || (a.value == '')) ? -1 : 1;
				// return a.text == $(selectId + 'option:first').text ? -1 : a.text < b.text ? -1 : 1;
			}));

			// Select one option.
			$(this).val(selectedValue);
		});
	}
</script>
<div id="editCipeprojectDiv">
	<form:form name="editCipeprojectForm" id="editCipeprojectForm" action="saveCipeprojectDetail.do" method="post" modelAttribute="cipeproject">
		<div id="dialogContainer"></div>
		<form:hidden path="id" />
		<form:hidden path="costCenterNumber" />
		<c:choose>
			<c:when test="${param.editable=='true'}">
				<input type="hidden" name="editable" value="true" />
			</c:when>
			<c:otherwise>
				<input type="hidden" name="editable" value="false" />
			</c:otherwise>
		</c:choose>
		<div class="main_form">
			<div class="form_head">
				<div class="floatL" style="padding-top: 5px;">
					<a href="#" class="blue_btn" id="view-loggedpayments" cipeprojectId="${cipeproject.id}"> <spring:message code="editCipeprojectSummary.link.payments" />
					</a> <a href="#" class="blue_btn" id="view-knowledgemanagement" cipeprojectId="${cipeproject.id}"> <spring:message code="editCipeprojectSummary.link.knowledgemanagement" />
					</a> <a href="#" class="blue_btn" id="view-modifications" cipeprojectId="${cipeproject.id}"> <spring:message code="editCipeprojectSummary.link.modifications" />
					</a> <a href="#" class="blue_btn" id="view-rollup" cipeprojectId="${cipeproject.masterProject.id}"> <spring:message code="editCipeprojectSummary.link.rollup" />
					</a> <a href="#" class="blue_btn" id="mail-to-trigger" cipeprojectId="${cipeproject.projectID}"> <spring:message code="editCipeprojectSummary.link.notify" />
					</a>
				</div>
				<a href="#" class="close-button gray_btn floatR">Close Form</a><br class="clear" />
			</div>
			<div class="form_cont">
				<table cellspacing="10" width="100%">
					<!-- 
					<tr class="row">
						<td class="menu-heading" colspan="3"><spring:message code="editCipeprojectDetail.heading" /></td>
					</tr>
					 -->
					<tr class="row">
						<td class="input-field" colspan="5"><%@ include file="/common/messages.jsp"%></td>
					</tr>
					<tr>
						<td style="vertical-align: top;">
							<table>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.type" /></td>
									<td class="input-field"><form:select path="cipeprojecttype.id" cssClass="input-full-width-req text_blue" tabindex="1">
											<form:option value="" label="Select" />
											<form:options items="${cipeprojecttypeList}" itemValue="id" itemLabel="displayName" />
										</form:select> <form:errors path="cipeprojecttype.id" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.costCenter" /></td>
									<td class="input-field"><form:input path="costCenterNumber" id="costCenterNumber" cssClass="input-full-width-req text_blue" tabindex="2" /> <form:errors path="costCenterNumber" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.projectID" /></td>
									<td class="input-field"><form:input path="projectID" cssClass="input-full-width text_grey" tabindex="3" /> <form:errors path="projectID" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.partner" /></td>
									<td class="input-field" nowrap="nowrap"><form:select path="partner.id" cssClass="input-full-width-req text_blue" tabindex="4">
											<form:option value="" label="Select" />
											<form:options items="${partnerList}" itemValue="id" itemLabel="partnerName" style="word-wrap:break-word;width:410px;" />
										</form:select> <input type="button" id="add-partner" class="blue_btn" value="<spring:message code="link.add" />" cipeprojectId="${cipeproject.id}" tabindex="5" /> <form:errors path="partner.id" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.donorAwardID" /></td>
									<td class="input-field" nowrap="nowrap"><form:select id="donorawardId" path="donoraward.id" cssClass="input-full-width-req text_blue" tabindex="6">
											<form:option value="" label="Select" />
											<form:options items="${donorawardList}" itemValue="id" itemLabel="donorAwardNumber" />
										</form:select> <input type="button" class="blue_btn" id="edit-donoraward" value="<spring:message code="link.view" />" tabindex="7" /> <form:errors path="donoraward.id" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.donorName" /></td>
									<td class="input-field"><form:input path="" readonly="true" cssClass="input-full-width text_grey" id="donorName" tabindex="8" /> <form:errors path="" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.donorStartDate" /></td>
									<td class="input-field"><form:input path="" readonly="true" cssClass="input-full-width text_grey" id="donorStartDate" tabindex="9" /> <form:errors path="" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.donorEndDate" /></td>
									<td class="input-field"><form:input path="" readonly="true" cssClass="input-full-width text_grey" id="donorEndDate" tabindex="10" /> <form:errors path="" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.startDate" /></td>
									<td class="input-field"><form:input path="projectStartDate" cssClass="input-full-width-req text_blue" onchange="getFiscalYear()" /> <form:errors path="projectStartDate" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.endDate" /></td>
									<td class="input-field"><form:input path="projectEndDate" cssClass="input-full-width-req text_blue" tabindex="12" /> <form:errors path="projectEndDate" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.acronym" /></td>
									<td class="input-field"><form:input path="acronym" cssClass="input-full-width-req text_blue" tabindex="13" /> <form:errors path="acronym" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.projectTitle" /></td>
									<td class="input-field"><form:input path="projectTitle" cssClass="input-full-width-req text_blue" tabindex="14" /> <form:errors path="projectTitle" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.region" /></td>
									<td class="input-field"><form:select path="region.id" cssClass="input-full-width-req text_blue" id="regions" tabindex="15">
											<form:option value="" label="Select" />
											<form:options items="${regionList}" itemValue="id" itemLabel="displayName" />
										</form:select> <form:errors path="region.id" cssClass="error" /></td>
									<td><form:errors path="region.id" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.country" /></td>
									<td class="input-field"><form:select path="country.id" id="countries" cssClass="input-full-width-req text_blue" tabindex="16">
											<form:option value="" label="Select" />
											<form:options items="${countryList}" itemValue="id" itemLabel="displayName" />
										</form:select> <form:errors path="country.id" cssClass="error" /></td>
									<td><form:errors path="country.id" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.status" /></td>
									<td class="input-field"><form:select path="cipeprojectstatus.id" cssClass="input-full-width-req text_blue" tabindex="17">
											<form:options items="${cipeprojectstatusList}" itemValue="id" itemLabel="displayName" />
										</form:select> <form:errors path="cipeprojecttype.id" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="input-field" align="center" colspan="2">
										<%--
							<c:choose>
								<c:when test="${cipeproject.id !=null and cipeproject.id gt 0}">
								   <c:choose>
								      <c:when test="${param.editable!='true'}">
									    <input class="blue_btn" id="editButton" type="button" value="Edit" cipeprojectId="${cipeproject.id}"/>
								      </c:when>
								      <c:otherwise>	
									      <input class="blue_btn" id="cancelButton" type="reset" value="<spring:message code='button.cancel' />" />
									      <sj:submit cssClass="blue_btn" id="loginFormSubmit" target="editCipeprojectDiv" key="editCipeproject.button.save" validate="true" />
								      </c:otherwise>
								   </c:choose>  	
								</c:when>
								<c:otherwise>
								 <input class="blue_btn" id="editButton" type="button" value="Edit" cipeprojectId="${cipeproject.id}"/>
									<input class="blue_btn" id="cancelButton" type="reset" value="<spring:message code='button.cancel' />" />
									<sj:submit cssClass="blue_btn" id="loginFormSubmit" target="editCipeprojectDiv" key="editCipeproject.button.save" validate="true" />
								</c:otherwise>
							</c:choose>
							 --%> <input class="blue_btn" id="editButton" type="button" value="Edit" cipeprojectId="${cipeproject.id}" tabindex="34" /> <input class="blue_btn" id="cancelButton" type="button" value="<spring:message code='button.cancelEdit' />"
										cipeprojectId="${cipeproject.id}" tabindex="35"
									/> <sj:submit cssClass="blue_btn" id="loginFormSubmit" target="editCipeprojectDiv" key="editCipeproject.button.save" validate="true" tabindex="36" />
									</td>
								</tr>
							</table>
						</td>
						<td style="vertical-align: top;">
							<table>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.seniorProgramOfficer" /></td>
									<td class="input-field"><form:select id="seniorProgramOfficer" path="seniorProgramOfficer.id" cssClass="input-full-width-req text_blue" tabindex="18">
											<form:option value="" label="Select" />
											<form:options items="${seniorProgramOfficerList}" itemValue="id" itemLabel="fullName" />
										</form:select> <form:errors path="seniorProgramOfficer.id" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.programOfficer" /></td>
									<td class="input-field"><form:select id="programOfficer" path="programOfficer.id" cssClass="input-full-width-req text_blue" tabindex="19">
											<form:option value="" label="Select" />
											<form:options items="${programOfficerList}" itemValue="id" itemLabel="fullName" />
										</form:select> <form:errors path="programOfficer.id" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.programAssistant" /></td>
									<td class="input-field"><form:select id="programAssistant" path="programAssistant.id" cssClass="input-full-width-req text_blue" tabindex="20">
											<form:option value="" label="Select" />
											<form:options items="${programAssistantList}" itemValue="id" itemLabel="fullName" />
										</form:select> <form:errors path="programAssistant.id" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.managementFunds" /></td>
									<td class="input-field"><form:input path="managementFunds" cssClass="input-full-width-req text_blue" tabindex="21" /> <%-- <div id="managementFundsLabel" class="input-sub input-full-width-req text_blue">&nbsp;</div>--%> <form:errors
											path="managementFunds" cssClass="error"
										/></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.nedIdentifier" /></td>
									<td class="input-field"><form:input path="nedIdentifier" cssClass="input-full-width text_white" tabindex="22" /> <form:errors path="nedIdentifier" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.rollupProject" /></td>
									<td class="input-field"><form:select path="masterProject.id" cssClass="text_white" tabindex="23">
											<form:option value="" label="Select" />
											<form:options items="${cipeprojectrollupList}" itemValue="id" itemLabel="projectTitle" />
										</form:select> <form:errors path="masterProject.id" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.fiscalYear" /></td>
									<td class="input-field"><form:input path="fiscalYear" cssClass="input-full-width text_blue" tabindex="24" /> <form:errors path="fiscalYear" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.memo" /></td>
									<td class="input-field"><form:input path="memo" cssClass="input-full-width text_white" tabindex="25" /> <form:errors path="memo" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.fileLocation" /></td>
									<td class="input-field"><form:input path="fileLocation" cssClass="input-full-width text_white" tabindex="26" /> <form:errors path="fileLocation" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.approvedFileLocation" /></td>
									<td class="input-field"><form:input path="approvedFileLocation" cssClass="input-full-width text_white" tabindex="27" /> <form:errors path="approvedFileLocation" cssClass="error" /></td>
								</tr>
								<%--
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.modificationDocument" /></td>
									<td class="input-field" nowrap="nowrap"><form:input path="modificationDocumentLocation" cssClass="input-full-width text_white" /> <input id="chooseFileButton" type="button" class="blue_btn" value="Browse.."></td>
								</tr>
							 	--%>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.blockTimeSheet" /></td>
									<td class="input-field"><form:checkbox path="blockTimeSheet" cssClass="input-full-width" value="true" tabindex="28" /> <form:errors path="blockTimeSheet" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="editCipeproject.label.override" /></td>
									<td class="input-field"><form:checkbox path="override" cssClass="input-full-width" value="true" tabindex="29" /> <form:errors path="override" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="label.createdBy" /></td>
									<td class="input-field"><form:input readonly="true" path="createdBy.fullName" cssClass="input-full-width text_grey" tabindex="30" /> <form:errors path="createdBy" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="label.creationDate" /></td>
									<td class="input-field"><form:input readonly="true" path="creationDate" cssClass="input-full-width text_grey" tabindex="31" /> <form:errors path="creationDate" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="label.updatedBy" /></td>
									<td class="input-field"><form:input readonly="true" path="updatedBy.fullName" cssClass="input-full-width text_grey" tabindex="32" /> <form:errors path="updatedBy" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td class="label"><spring:message code="label.updationDate" /></td>
									<td class="input-field"><form:input readonly="true" path="updationDate" cssClass="input-full-width text_grey" tabindex="33" /> <form:errors path="updationDate" cssClass="error" /></td>
								</tr>
								<tr class="row">
									<td colspan="2">
										<table>
											<tr>
												<th></th>
												<th>Budget Amount</th>
												<th>Disbursed Amount</th>
												<th>Balance Amount</th>
											</tr>
											<tr>
												<td><b>Management Amnt:</b></td>
												<td><fmt:formatNumber type="currency" value="${cipeproject.projectBudgetAmount}" pattern="$#,##0;" /></td>
												<td><fmt:formatNumber type="currency" value="${cipeproject.projectDisbursedAmount}" pattern="$#,##0;" /></td>
												<td><fmt:formatNumber type="currency" value="${cipeproject.projectBalanceAmount}" pattern="$#,##0;" /></td>
											</tr>
											<tr>
												<td><b>Partner Grant/s:</b></td>
												<td><fmt:formatNumber type="currency" value="${cipeproject.totalPartnerBudgetAmount}" pattern="$#,##0;" /></td>
												<td><fmt:formatNumber type="currency" value="${cipeproject.totalPartnerDisbursedAmount}" pattern="$#,##0;" /></td>
												<td><fmt:formatNumber type="currency" value="${cipeproject.totalPartnerBalanceAmount}" pattern="$#,##0;" /></td>
											</tr>
											<tr>
												<td><b>Total:</b></td>
												<td><fmt:formatNumber type="currency" value="${cipeproject.totalProjectPartnerBudgetAmount}" pattern="$#,##0;" /></td>
												<td><fmt:formatNumber type="currency" value="${cipeproject.totalProjectPartnerDisbursedAmount}" pattern="$#,##0;" /></td>
												<td><fmt:formatNumber type="currency" value="${cipeproject.totalProjectPartnerBalanceAmount}" pattern="$#,##0;" /></td>
											</tr>
											<tr>
												<td><b>#Linked Sub-Grants:</b></td>
												<td>${fn:length(childCipeprojectList)}</td>
												<td></td>
												<td></td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
				<div>
					<spring:message code="editCipeprojectDetail.heading.grants" />
				</div>
				<div id="cipeprojectListDiv" class="hastable" style="overflow: auto">
					<table class="tablesorter">
						<thead>
							<tr>
								<th><spring:message code="partnergrantlist.table.heading.projectID" /></th>
								<th><spring:message code="partnergrantlist.table.heading.projectSponsor" /></th>
								<th><spring:message code="partnergrantlist.table.heading.acronym" /></th>
								<th><spring:message code="partnergrantlist.table.heading.budget" /></th>
								<th><spring:message code="partnergrantlist.table.heading.disbursed" /></th>
								<th><spring:message code="partnergrantlist.table.heading.balance" /></th>
								<th><spring:message code="partnergrantlist.table.heading.projectTitle" /></th>
								<th><spring:message code="partnergrantlist.table.heading.startDate" /></th>
								<th><spring:message code="partnergrantlist.table.heading.endDate" /></th>
								<th><spring:message code="partnergrantlist.table.heading.status" /></th>
								<th><spring:message code="partnergrantlist.table.heading.ingrants" /></th>
								<th><spring:message code="partnergrantlist.table.heading.agreement" /></th>
								<th><spring:message code="partnergrantlist.table.heading.autho" /></th>
								<th><spring:message code="partnergrantlist.table.heading.bank" /></th>
								<!-- <th><spring:message code="partnergrantlist.table.heading.type" /></th>
								<th><spring:message code="partnergrantlist.table.heading.programOfficer" /></th>
								<th><spring:message code="partnergrantlist.table.heading.region" /></th>
								<th><spring:message code="partnergrantlist.table.heading.country" /></th>
								<th><spring:message code="partnergrantlist.table.heading.managementFunds" /></th> -->
								<%--<th><spring:message code="partnergrantlist.table.heading.edit" /></th> --%>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${childCipeprojectList}" var="cipeproject">
								<tr>
									<td>${cipeproject.projectID}</td>
									<td><a href="javascript://" class="edit-partnergrant-link" partnergrantId="${cipeproject.id}">${cipeproject.acronym} <spring:message code="label.separator" /> ${cipeproject.partner.partnerName}
									</a></td>
									<td>${cipeproject.acronym}</td>
									<%--<td><a href="javascript://" class="edit-partnergrant-link" partnergrantId="${cipeproject.id}">${cipeproject.projectID}</a></td> --%>
									<td><spring:message code="label.dollar" />${cipeproject.partnerBudgetAmount}</td>
									<td><spring:message code="label.dollar" />${cipeproject.partnerDisbursedAmount}</td>
									<td><spring:message code="label.dollar" />${cipeproject.partnerBalanceAmount}</td>
									<td>${cipeproject.projectTitle}</td>
									<td><fmt:formatDate pattern="MM-dd-yyyy" value="${cipeproject.projectStartDate}" /></td>
									<td><fmt:formatDate pattern="MM-dd-yyyy" value="${cipeproject.projectEndDate}" /></td>
									<td>${cipeproject.cipeprojectstatus.displayName}</td>
									<td>${cipeproject.receivedingrantsforapproval}</td>
									<td>${cipeproject.receiptOfSignedAgreement}</td>
									<td>${cipeproject.receiptOfSignatureAuthorization}</td>
									<td>${cipeproject.receiptOfBankInformation}</td>
									<!--<td>${cipeproject.cipeprojecttype.displayName}</td>
									<td>${cipeproject.programOfficer.fullName}</td>
									<td>${cipeproject.region.displayName}</td>
									<td>${cipeproject.country.displayName}</td>
									<td>${cipeproject.managementFunds}</td>-->
									<%--<td><a href="javascript://" class="edit-partnergrant-link" partnergrantId="${cipeproject.id}"><spring:message code="partnergrantlist.table.link.edit" /></a></td> --%>
								</tr>
							</c:forEach>
						</tbody>
					</table>
					<div id="cipeprojectawardListPager"></div>
				</div>
				<br class="clear" /> <br class="clear" /> <br class="clear" />
				<div>Project Modification</div>
				<table>
					<thead>
						<tr>
							<th>ID</th>
							<th>Modification Type</th>
							<th>Modified From</th>
							<th>Modified To</th>
							<th>Modified Date</th>
							<th>Modified By</th>
							<th>File Location of Modified Document</th>
						</tr>
					</thead>
					<tbody>
						<c:choose>
							<c:when test="${fn:length(cipeproject.cipeprojectmodifications) > 0}">
								<c:forEach items="${cipeproject.cipeprojectmodifications}" var="modification">
									<tr>
										<td>${modification.id}</td>
										<td>${modification.modificationType.modificationTypeDesc}</td>
										<td>${modification.modifiedFrom}</td>
										<td>${modification.modifiedTo}</td>
										<td>${modification.formattedModifiedDate}</td>
										<td>${modification.modifiedBy.fullName}</td>
										<td>${modification.attachment}</td>
									</tr>
								</c:forEach>
							</c:when>
							<c:otherwise>
								<tr>
									<td colspan="7" style="padding-left: 10px;">No modifications found.</td>
								</tr>
							</c:otherwise>
						</c:choose>
					</tbody>
				</table>
			</div>
		</div>
	</form:form>
</div>